import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '资产名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '资产分类',
    align: 'center',
    dataIndex: 'category_dictText',
  },
  {
    title: '管理部门',
    align: 'center',
    dataIndex: 'deparment_dictText',
  },
  {
    title: '存放地点',
    align: 'center',
    dataIndex: 'position_dictText',
  },
  {
    title: '单价',
    align: 'center',
    dataIndex: 'unitPrice',
  },
  {
    title: '库存数量',
    align: 'center',
    dataIndex: 'count',
  },
  {
    title: '可用数量',
    align: 'center',
    dataIndex: 'availableQuantity',
  },
  {
    title: '占用数量',
    align: 'center',
    dataIndex: 'quantityOccupied',
  },
  {
    title: '描述',
    align: 'center',
    dataIndex: 'description',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '资产名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
    componentProps: {
      type: 'like',
    },
  },
  {
    label: '资产分类',
    field: 'category',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'asset_category,category_name,id',
      pidField: 'pid',
      pidValue: '0',
      hasChildField: 'has_child',
    },

    colProps: { span: 6 },
  },
  {
    label: '管理部门',
    field: 'deparment',
    component: 'JDictSelectTag',
    componentProps: {},
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '资产名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入资产名称!' }];
    },
  },
  {
    label: '资产分类',
    field: 'category',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'asset_category,category_name,id',
      pidField: 'pid',
      pidValue: '0',
      hasChildField: 'has_child',
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入资产分类!' }];
    },
  },
  {
    label: '管理部门',
    field: 'deparment',
    component: 'JSelectDept',
    componentProps: {
      isRadioSelection: true,
      checkStrictly: true,
      multiple: false,
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入管理部门!' }];
    },
  },
  {
    label: '资产来源',
    field: 'source',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'assetSource',
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入资产来源!' }];
    },
  },
  {
    label: '存放地点',
    field: 'position',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'asset_position,position_name,id',
      pidField: 'pid',
      pidValue: '0',
      hasChildField: 'has_child',
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入存放地点!' }];
    },
  },
  {
    label: '单价',
    field: 'unitPrice',
    component: 'InputNumber',
    dynamicRules: () => {
      return [{ required: true, message: '请输入单价!' }];
    },
    componentProps: {
      min: 0,
    },
  },
  {
    label: '数量',
    field: 'count',
    component: 'InputNumber',
    dynamicRules: () => {
      return [{ required: true, message: '请输入数量!' }];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
  },

  {
    label: '入库图片',
    field: 'image',
    component: 'JImageUpload',
    componentProps: {},
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
//子表单数据
//子表表格配置
export const assetWarehousingDetailColumns: JVxeColumn[] = [
  {
    title: '存放位置',
    key: 'position',
    type: JVxeTypes.select,
    options: [],
    dictCode: '',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '资产编码',
    key: 'code',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: 'RFID编码',
    key: 'rfid',
    type: JVxeTypes.select,
    options: [],
    dictCode: '',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '管理部门',
    key: 'custodyDepartment',
    type: JVxeTypes.select,
    options: [],
    dictCode: '',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
